package org.lemon.springmysqltest.common;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.orm.ObjectOptimisticLockingFailureException;

/**
 * 全局异常处理器
 *
 * @author : Lemon
 * @date : 2025-05-21 22:59
 **/
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 处理乐观锁异常
     */
    @ExceptionHandler(ObjectOptimisticLockingFailureException.class)
    public String handleOptimisticLockException(ObjectOptimisticLockingFailureException e) {
        return "订单数据被并发修改，请稍后重试。";
    }
}
